package com.rayo.accesscontrollercopy.config;


import com.rayo.accesscontrollercopy.model.db.bean.ReaderData;
import com.rayo.accesscontrollercopy.model.db.bean.SiteData;
import com.rayo.accesscontrollercopy.model.db.bean.SystemData;
import com.rayo.accesscontrollercopy.model.db.dao.ReaderDataDao;
import com.rayo.accesscontrollercopy.model.db.dao.ReaderDataImpl;
import com.rayo.accesscontrollercopy.model.db.dao.SiteDao;
import com.rayo.accesscontrollercopy.model.db.dao.SiteImpl;
import com.rayo.accesscontrollercopy.model.db.dao.SystemDataDao;
import com.rayo.accesscontrollercopy.model.db.dao.SystemDataImpl;

/**
 * Created by yanghaojie on 16/7/26.
 */
public class GlobalVariables {
    private volatile static GlobalVariables uniqueInstance;

    private SystemData mSystemData;
    private ReaderData mReaderData;
    private SiteData mSiteData;
    private String mAndroidId;

    private SystemDataDao mSystemDataDao = new SystemDataImpl();
    private ReaderDataDao mReaderDataDao = new ReaderDataImpl();
    private SiteDao mSiteDao = new SiteImpl();

    public static GlobalVariables getInstance() {
        if (uniqueInstance == null) {
            synchronized (GlobalVariables.class) {
                if (uniqueInstance == null) {
                    uniqueInstance = new GlobalVariables();
                }
            }
        }
        return uniqueInstance;
    }

    private GlobalVariables() {
        this.mSystemData = mSystemDataDao.findFirst();
        this.mReaderData = mReaderDataDao.findFirst();
        this.mSiteData = mSiteDao.findFirst();
        this.mAndroidId = "";
    }

    public String getAndroidId() {
        return mAndroidId;
    }

    public void setAndroidId(String androidId) {
        mAndroidId = androidId;
    }

    public SystemData getmSystemData() {
        return mSystemData;
    }

    public void setmSystemData(SystemData mSystemData) {
        this.mSystemData = mSystemData;
    }

    public ReaderData getmReaderData() {
        return mReaderData;
    }

    public void setmReaderData(ReaderData mReaderData) {
        this.mReaderData = mReaderData;
    }

    public SiteData getmSiteData() {
        return mSiteData;
    }

    public void setmSiteData(SiteData mSiteData) {
        this.mSiteData = mSiteData;
    }

}
